# Importing Data
AZERBAJAN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "D1:D229")

# Checking the Imported Data
View(AZERBAJAN)
# Creating Time Series Data
AZERBAJAN_ts <- ts(AZERBAJAN, start=c(2003,1), end=c(2016,12), frequency=12)
# Viewing and Checking the Created Time Series Data
AZERBAJAN_ts
sum(is.na(AZERBAJAN_ts))
library(forecast)
AZERBAJAN_ts <- tsclean(AZERBAJAN_ts)
AZERBAJAN_ts

# Identification: Plotting the Time Series Data
plot(AZERBAJAN_ts)

# Estimating the appropriate model
AZERBAJAN_ts_model <- auto.arima(AZERBAJAN_ts)
AZERBAJAN_ts_model

# Forecasting
options(max.print=1000000)
AZERBAJAN_ts_forecast <- forecast (AZERBAJAN_ts_model, level=c(95), h=288)
plot(AZERBAJAN_ts_forecast)
AZERBAJAN_ts_forecast             

# Exporting
write.table(AZERBAJAN_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/AZERBAJAN_TSA.csv", sep=",")
